﻿using System;
using System.Web.UI;

using LMD.Constant;
using LMD.Lib.DataClass;
using LMD.Lib.Interface;
using DevExpress.Web.ASPxCallback;

public partial class _Default : MasterPage, IMasterPage
{
    public int m_iNotifCount = 0;
    public int m_iEventCount = 0;

    #region Event Handlers
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            InitNotifications();
            tmrDefault.Interval = KGlobal.NOTIFICATION_REFRESH_INTERVAL;
        }
    }
    #endregion Event Handlers

    #region Custom Methods

    private void InitNotifications()
    {
        Cached.NotificationTable ccNotif = new Cached.NotificationTable();
        m_iNotifCount = ccNotif.GetNotificationCount(ICPUser.ID);
        m_iEventCount = ccNotif.GetEventCount(ICPUser.ID);
    }

    public bool ShowSearchBox()
    {
        bool bShow = false;
        try
        {
            bShow = (Page as ICPGeneralPage).PageName.ToUpper().StartsWith("NEWSFEED.ASPX")
                || (Page as ICPGeneralPage).PageName.ToUpper().StartsWith("COMPANYPROFILE.ASPX");
        }
        catch { /* PAGE is not inheritance of ICPGeneralPage*/ }

        return bShow;
    }
	public bool MenuPriviledge(String sxMenu)
    {
        bool bShow = false;
        try
        {
            bShow = (Page as ICPGeneralPage).m_lsPrivilledges.Contains(sxMenu);
        }
        catch { }
        return bShow;
    }
    #endregion Custom Methods


    #region IMasterPage Members

    string IMasterPage.ReadSearchQuery()
    {
        return txtSearch.Value;
    }

    bool IMasterPage.IsSearchMode()
    {
        return searchmode.Value.ToUpper() == "Y";
    }
    void IMasterPage.SetSearchMode(bool IsOn)
    {
        searchmode.Value = IsOn ? "Y" : "N"; 
    }

    #endregion
}
